<template>
  <a-modal :maskClosable="false"
           :title="title"
           :width="900"
           :visible="visible"
           :confirmLoading="confirmLoading"
           @ok="handleOk"
           @cancel="handleCancel"
           cancelText="关闭">

    <a-spin :spinning="confirmLoading">
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
         <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)" v-if="record.readFlag=='0'">
                  <a>删除</a>
         </a-popconfirm>
        </span>
      </a-table>
    </a-spin>
  </a-modal>
</template>

<script>
import { httpAction } from '@/api/manage'
import pick from 'lodash.pick'
import { getAction } from '@/api/manage'
import moment from 'moment'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  mixins: [JeecgListMixin],
  components: {},
  name: 'SysAnnouncementModal',
  data() {
    return {
      title: '操作',
      visible: false,
      disableSubmit: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 4 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 18 }
      },
      labelColX1: {
        xs: { span: 24 },
        sm: { span: 4 }
      },
      wrapperColX1: {
        xs: { span: 24 },
        sm: { span: 18 }
      },
      confirmLoading: false,
      disableMixinCreated:true,
      queryParam: {},
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '接收用户',
          align: 'center',
          dataIndex: 'userName'
        },
        {
          title: '是否阅读',
          align: 'center',
          dataIndex: 'readFlag',
          customRender: function(text) {
            if (text == '1') {
              return '己读'
            }
            return "未读";
          }
        },
        {
          title: '阅读时间',
          align: 'center',
          dataIndex: 'sendTime',
          customRender: function(t, r, index) {
             if(t==null){
               return "~"
             }
             return t;
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      detailModal: { visible: false, url: '' },
      url: {
        list: '/sys/annountCement/user/list',
        delete: '/sys/annountCement/user/delete'
      }
    }
  },
  created() {
  },
  methods: {
    add() {
      this.edit({})
    },
    edit(record) {
      this.model = {}
      this.visible = true
      this.queryParam.anntId=record.id;
      this.loadData();
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      this.close()
    },
    handleCancel() {
      this.visible = false
      this.$emit('close')
    }
  }
}
</script>

<style scoped>

</style>